package com.mengtian_tech.tju.dataquery.api.controller;

import java.text.ParseException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.mengtian_tech.tju.dataquery.api.util.ResponseUtil;

@RestController
@RequestMapping("/api/car")
public class CarController {
	
	@Autowired
	@Qualifier("jdbcTemplateDataAi")
	JdbcTemplate jdbcTemplateDataAi;
	

	@RequestMapping("rpt")
	public Object rpt(String begin,String end,String school) throws ParseException {
		
		 
		//获取请假数量
		List<Map<String,Object>> list = this.jdbcTemplateDataAi.queryForList(
				"select  sum(car_count) cnt , date_on from rpt_car_park  where"
				+ " date_on >=? and date_on <= ?  and IN_PASS_NAME like ? "
				+ " group by date_on   order by date_on asc"
				,begin,end,school+"%");
		
		Map<String,Object> result = new HashMap<String, Object>();
		result.put("rpt1", list);
		return ResponseUtil.ok(result);
	}
	
}
